<template>
  <div class="page-container" v-loading="loading" v-loadingCommonStyle>
    <ex_header_spiler :title="$tt('label_base_info')" />

    <ex_super_desc v-bind="baseOption" :data="form" :attrs="$defaultDetailDescAttrs">
    </ex_super_desc>
    <ex_header_spiler :title="$tt('label_transit_measure')" />
    <ex_super_desc v-bind="transitMeasureOption" :data="form" :attrs="$defaultDetailDescAttrs" />
    <ex_header_spiler :title="$tt('label_handle_info')" />
    <ex_super_desc v-bind="otherOption" :data="form" :attrs="$defaultDetailDescAttrs" />
    <ex_header_spiler :title="$tt('label_measure_detail')">
    </ex_header_spiler>
    <ex_super_table v-bind="tableOption" :data="form.detailList" size="default" height="400">

    </ex_super_table>


  </div>
</template>
<script>


import router_params from '@/mixin/router_params';
export default {

  title: "label_order_measure_deviation",
  mixins: [router_params],
  components: {},


  data() {
    return {
      loading: false,

      form: {},
      baseOption: {
        model: [
          { key: 'receivingOrderCode', label: 'label_inbound_code', formType: 'text', },

          {
            key: 'customerName', label: 'label_customer_name', formType: 'text',
            formatter: (r, c, v) => this.$formatNameCode(v, r.customerCode)
          },
          {
            key: 'totalWeight', label: 'label_order_weight', formType: 'text',
            formatter: (r, c, v, i) => this.$addUnit(v, "kg")

          },
          {
            key: 'totalVolume', label: 'label_measure_volume', formType: 'text',
            formatter: (r, c, v, i) => this.$addUnit(v, "m³")
          },
          {
            key: 'bizType', label: 'label_business_type', formType: 'text',
            formatter: (r, c, v, i) => this.$enumShow(v, "BizTypeEnum")
          },
          {
            key: 'deviationRate', label: 'label_customer_config_deviation_rate', formType: 'text',
            formatter: (r, c, v, i) => this.$addUnit(v ? v : "0", "%")
          },
        ],
      },
      transitMeasureOption: {
        model: [
          {
            key: 'isTransitMeasure', label: 'label_is_transfer_measure', formType: 'text',
            formatter: (r, c, v, i) => this.$enumShow(v ? v : "N", "YesOrNoEnum")
          },
          {
            key: 'transitMeasureTime', label: 'label_transfer_measure_time', formType: 'text',
            if: (data) => data.isTransitMeasure == "Y",
            render: (h, { data, item }) => this.$renderText(h, this.$dateFormat(data[item.key]))

          },
          {
            key: 'transitMeasureTotalWeight', if: (data) => data.isTransitMeasure == "Y",
            label: 'label_transit_measure_weight', formType: 'text',
            formatter: (r, c, v, i) => this.$addUnit(v, "kg")
          },
          {
            key: 'transitMeasureTotalVolume', if: (data) => data.isTransitMeasure == "Y",
            label: 'label_transit_measure_volume', formType: 'text',
            formatter: (r, c, v, i) => this.$addUnit(v, "m³")
          },
          {
            key: 'transitMeasureDeviationRate', label: 'label_transfer_measure_deviation_rate', formType: 'text',
            if: (data) => data.isTransitMeasure == "Y",
            render: (h, { data, item }) => this.$renderText(h, this.$addUnit(data[item.key], "%"))

          },
          {
            key: 'transitMeasureUserName', if: (data) => data.isTransitMeasure == "Y",
            label: 'label_transit_measure_user', formType: 'text',
            formatter: (r, c, v, i) => this.$formatNameCode(v, r.transitMeasureUserCode)
          },
        ],
      },
      otherOption: {
        model: [
          {
            key: 'disposeMode', label: 'label_do_with_method', formType: 'text',
            render: (h, { data, item }) => this.$renderText(h, this.$enumShow(data[item.key], "OrderDifferenceDisposeModeEnum"))


          },
          {
            key: 'disposeDifferenceRate', label: 'label_process_variance_ratio', formType: 'text',
            render: (h, { data, item }) => this.$renderText(h, this.$addUnit(data[item.key], "%"))

          },
          {
            key: 'disposeTime', label: 'label_handler_time', formType: 'text',
            render: (h, { data, item }) => this.$renderText(h, this.$dateFormat(data[item.key]))

          },
          {
            key: 'disposeUserName', label: 'label_handler_user', formType: 'text',
            render: (h, { data, item }) => this.$renderText(h, (data[item.key]))

          },
          {
            key: 'attachedList', label: 'label_handler_attachment', type: 'ex_super_upload', span: 4,
            attrs: {
              disabled: true,
              type: "file",
              limit: 10,
            }
          },


          {
            key: 'confirmUserName', label: 'label_confirm_user', formType: 'text',
            render: (h, { data, item }) => this.$renderText(h, (data[item.key]))


          },
          {
            key: 'confirmTime', label: 'label_confirm_time', formType: 'text',
            render: (h, { data, item }) => this.$renderText(h, this.$dateFormat(data[item.key]))

          },

          {
            key: 'closeUserName', label: 'label_close_user', formType: 'text',
            render: (h, { data, item }) => this.$renderText(h, (data[item.key]))

          },
          {
            key: 'closeTime', label: 'label_close_time', formType: 'text',
            render: (h, { data, item }) => this.$renderText(h, this.$dateFormat(data[item.key]))

          },
        ],
      },
      tableOption: {
        model: [
          {
            key: 'boxNo', label: 'label_box_code', 'min-width': 200,
            propertyFilter: true, sortable: true,
          },
          {
            key: 'weight', label: 'label_expect_box_weight', 'width': 160,
            propertyFilter: true, sortable: true,
            formatter: (r, c, v, i) => this.$addUnit(v, "kg")
          },
          {
            key: 'volume', label: 'label_expect_box_volume', 'width': 160,
            propertyFilter: true, sortable: true,
            formatter: (r, c, v, i) => this.$addUnit(v, "m³")
          },
          {
            key: 'transitMeasureWeight', label: 'label_transit_measure_weight', 'width': 160,
            propertyFilter: true, sortable: true,
            formatter: (r, c, v, i) => this.$addUnit(v, "kg")
          },
          {
            key: 'transitMeasureVolume', label: 'label_transit_measure_volume', 'width': 160,
            propertyFilter: true, sortable: true,
            formatter: (r, c, v, i) => this.$addUnit(v, "m³")
          },
          {
            key: 'differenceWeight', label: 'label_weight_diff', 'width': 130,
            propertyFilter: true, sortable: true,
          },
          {
            key: 'differenceVolume', label: 'label_volume_diff', 'width': 130,
            propertyFilter: true, sortable: true,
          },

        ],
      }
    };
  },

  computed: {

  },
  methods: {

    init_data_default(into_params) {
      if (into_params.id) {
        this.loading = true
        this.$ajax({
          url: "/oms-api/anomaly/OmsBaseOrderDifferenceRpc/selectDetail.json",
          method: 'post',
          data: { id: into_params.id },
          success: (res) => {
            this.loading = false
            this.form = Object.assign({}, res.data)
            this.fixTabLabel()

          }
        })
      }
      this.fixTabLabel()
    },
    fixTabLabel() {
      if (!!this.form.receivingOrderCode) {
        this.$emit("tagModifyLabel", { _key: 'label_name_code', name: this.$tt('label_order_measure_deviation'), code: this.form.receivingOrderCode || '' })
      } else {
        this.$emit("tagModifyLabel", "label_order_measure_deviation")
      }
    },
  }
};

</script>
<style></style>
